//
//  SoftwareShareViewController.m
//  Housekeeping
//
//  Created by 辰领科技 on 16/5/30.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "SoftwareShareViewController.h"
#import "SoftwareShareTableViewCell.h"
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
#import "UMSocialQQHandler.h"

static NSString *CellIdentifier =@"SoftwareShareTableViewCell";

@interface SoftwareShareViewController ()
<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation SoftwareShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
}



- (void)initViewLayout {
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    
    [self.tableView registerNib:[UINib nibWithNibName:CellIdentifier bundle:nil] forCellReuseIdentifier:CellIdentifier];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.showsVerticalScrollIndicator = NO;
    
}

#pragma mark - <UITableViewDelegate&&UITableViewDataSource>
//定义 UITableView cell 的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

//定义 UITableView cell 的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 46*VerticalRatio();
}

//定义 UITableView cell 展示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SoftwareShareTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell) {
        cell = [[SoftwareShareTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    NSArray * names = @[@"微信好友",@"微信朋友圈",@"QQ好友",@"QQ空间",@"新浪微博",@"腾讯微博"];
    cell.softwareLabel.text = names[indexPath.row];
    cell.softwareImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@%d",@"SoftwareShare",indexPath.row+1]];
    if (indexPath.row == 4 || indexPath.row == 5) {
        cell.isAuthorizationLable.hidden = NO;
    }else {
        cell.isAuthorizationLable.hidden = YES;
    }
    
    return cell;
}

//定义 UITableView cell 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0:
        {
            [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatSession] content:@"家政就找叮咚阿姨" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                if (response.responseCode == UMSResponseCodeSuccess) {
                    //            NSLog(@"分享成功！");
                }
            }];

        }
            break;
        case 1:
        {
            [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:@"家政就找叮咚阿姨" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                if (response.responseCode == UMSResponseCodeSuccess) {
                    //            NSLog(@"分享成功！");
                }
            }];
        }
            break;
        case 2:
        {
            [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQQ] content:@"家政就找叮咚阿姨" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                if (response.responseCode == UMSResponseCodeSuccess) {
                    //            NSLog(@"分享成功！");
                }
            }];
        }
            break;
        case 3:
        {
            [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQzone] content:@"家政就找叮咚阿姨" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
                if (response.responseCode == UMSResponseCodeSuccess) {
                    //            NSLog(@"分享成功！");
                }
            }];
        }
            break;
        default:
            break;
    }
}

#pragma mark - 返回
- (IBAction)back:(id)sender {
    [self backBtn];
}


@end
